class Solution {
    public int dayOfYear(String date) {
        String[] str = date.split("-");
        int year = Integer.parseInt(str[0]);
        int month = Integer.parseInt(str[1]);
        int day = Integer.parseInt(str[2]);
        int[] arr = {31,28,31,30,31,30,31,31,30,31,30,31};
        if((year % 4 == 0 && year % 100 != 0 )|| year % 400 == 0){
            arr[1] = 29;
        }
        int sum = 0;
        for(int i = 0; i < month-1; i++){
            sum += arr[i];
        }
        sum += day;
        return sum;
    }
}
